﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Imaging;
using System.Threading;
using System.Diagnostics;


namespace AIthin.Model
{
    public partial class MainForm : Form
    {
         public MainForm()
        {
            InitializeComponent();
            /* Create a listener that outputs to the console screen, and 
            // add it to the debug listeners. */
            DelimitedListTraceListener myWriter = new DelimitedListTraceListener(System.DateTime.Now.ToString().Replace(' ', '_').Replace(':', '-') + ".log", "log");
            myWriter.TraceOutputOptions = TraceOptions.ProcessId;
            int idx = Debug.Listeners.Add(myWriter);
 //           Trace.Listeners[idx].Name = "log";
 //           Trace.Listeners["log"].TraceOutputOptions = TraceOptions.DateTime;

            Debug.WriteLine(System.DateTime.Now.ToString() + " start - **********");
            Debug.AutoFlush = true;
        }
        private void MainForm_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;          
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            if (AIthin.Model.Properties.Settings.Default.WorkingPath == "")
                setWorkingDirectoryToolStripMenuItem_Click(sender, e);
            this.Activate();
        }

        private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
        {

        }

        private void loadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openNNFileDialog.InitialDirectory = AIthin.Model.Properties.Settings.Default.WorkingPath;
            
            if (openNNFileDialog.ShowDialog() == DialogResult.OK)
            {
                NeuroNetworkForm NF1 = new NeuroNetworkForm();
                NF1.MdiParent = this;
                NF1.LoadNetworkFile(AIthin.Model.Properties.Settings.Default.WorkingPath, openNNFileDialog.SafeFileName);
                NF1.Show();
            }
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LearnSetForm LearnSetForm1 = new LearnSetForm();
            LearnSetForm1.MdiParent = this;
            LearnSetForm1.Show();
        }

        private void setWorkingDirectoryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            folderBrowserDialog1.ShowDialog();
            AIthin.Model.Properties.Settings.Default.WorkingPath = folderBrowserDialog1.SelectedPath;
            AIthin.Model.Properties.Settings.Default.Save();
        }

    
        private void fNetworkToolStripMenuItem_Click(object sender, EventArgs e)
        {
            NewNetworkForm T = new NewNetworkForm();
            T.MdiParent = this;
            T.Show();
        }

        private void viewToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void reportToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }
    }
}
